package com.ls.controller.weixin;

import com.ls.controller.weixin.model.RefundModel;
import com.ls.service.IWeixinPayService;
import com.ls.utils.ResultData;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 微信支付 前端控制器
 * </p>
 *
 * @author pengyu
 * @since 2024-10-12
 */
@Api(value = "微信支付相关接口", tags = "微信支付相关接口")
@Slf4j
@RestController
@RequestMapping("/weixin")
@RequiredArgsConstructor
public class WeixinPayController {
    private final IWeixinPayService service;
    /** 关闭订单 */
    @PostMapping("/closeOrder")
    public ResultData closeOrder(@Valid @RequestBody String orderNum) {
        log.info("支付回调");
        return service.closeOrder(orderNum);
    }
    /** 退款 */
    @PostMapping("/refundWeixin")
    public ResultData refundWeixin(@Valid @RequestBody RefundModel model) {
        log.info("支付回调:{}",model.getMoney());
        return service.refundWeixin(model.getOrderNum(), model.getMoney());
    }
}
